package com.axxy.status;

/**
 * @author 一缕茜阳
 * @date 2021/8/31
 */
public class StatusTest {
    public static void main(String[] args) {
        Yasuo yasuo = new Yasuo();
        yasuo.Q();
        yasuo.Q();
        yasuo.Q();
        yasuo.Q();
        yasuo.Q();
    }
}
class Yasuo {
    private SkillStatus status;

    public Yasuo() {
        this.status = new OneTimeQStatus(this);
    }

    public SkillStatus getStatus() {
        return status;
    }

    public void setStatus(SkillStatus status) {
        this.status = status;
    }

    void Q() {
        status.execute();
    }
}

abstract class SkillStatus {

    protected Yasuo yasuo;
    protected int count;
    protected String status;

    abstract void execute();
}

class OneTimeQStatus extends SkillStatus {



    public OneTimeQStatus(Yasuo y) {
        yasuo = y;
        status = "Q1";
        count = 0;
    }


    public OneTimeQStatus(SkillStatus s) {
        yasuo = s.yasuo;
        status = "Q2";
        count = s.count;
    }

    @Override
    void execute() {
        System.out.println("斩钢闪1");
        count++;
        yasuo.setStatus(new TwoTimeQStatus(this));
    }
}

class TwoTimeQStatus extends SkillStatus {

    public TwoTimeQStatus(SkillStatus s) {
        yasuo = s.yasuo;
        status = "Q2";
        count = s.count;
    }

    @Override
    void execute() {
        System.out.println("斩钢闪2");
        count++;
        yasuo.setStatus(new ThirdTimeQStatus(this));
    }
}

class ThirdTimeQStatus extends SkillStatus {
    public ThirdTimeQStatus(SkillStatus s) {
        yasuo = s.yasuo;
        status = "Q3";
        count = s.count;
    }


    @Override
    void execute() {
        System.out.println("hasiki");
        count = 0;
        yasuo.setStatus(new OneTimeQStatus(this));
    }
}